/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tuan02;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Random;

/**
 *
 * @author XuanHung
 */
public class clsBT3 {
    private ArrayList arrInt;

    public clsBT3() {
        arrInt = new ArrayList();
    }
    
    public void PhatSinhSONguyen(int n){
        Random ran = new Random();        
        for (int i = 1; i <= n; i++){
            this.arrInt.add(ran.nextInt(n));
        }
    }
    public void GhiFile() throws FileNotFoundException{
        FileOutputStream fos = new FileOutputStream("integers.dat", true);
        PrintWriter fw = new PrintWriter(fos);
        BigInteger big; 
        for (int i = 0; i < arrInt.size(); i++) { 
            big = new BigInteger(arrInt.get(i).toString(),2);
            fw.print(big.toString(2));
        }
    }
    public void DocFile() throws FileNotFoundException, IOException{
        FileReader fr= new FileReader("integers.dat");
        BufferedReader input= new BufferedReader(fr);
        System.out.println(input.readLine());
                
    }
}
